//
//  QJAlertSimple.m
//  JHHQB
//
//  Created by jinrongweidian on 17/3/21.
//  Copyright © 2017年 我爱微点. All rights reserved.
//

#import "QJAlertSimple.h"

@implementation QJAlertSimple

+ (void)alertViewControllerWithAlertTitle:(NSString *)alertTitle alertMessage:(NSString *)alertMessage  actionTitle1:(NSString *)actionTitle1 actionTitle2:(NSString *)actionTitle2  cancelHandler:(void(^)())cancelHandler confirmHandler:(void(^)())confirmHandler alertFinishHandler:(void(^)())alertFinishHandler  object:(UIViewController *) object {
        
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:alertTitle message:alertMessage preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action1 = [UIAlertAction actionWithTitle:actionTitle1 style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        cancelHandler();
    }];
    
    UIAlertAction *action2 = [UIAlertAction actionWithTitle:actionTitle2 style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        confirmHandler();
    }];
    
    [alert addAction:action1];
    
    [alert addAction:action2];
    
    [object presentViewController:alert animated:YES completion:^{
        alertFinishHandler();
    }];
}


+ (void)alertViewControllerWithAlertTitle:(NSString *)alertTitle alertMessage:(NSString *)alertMessage  actionTitle:(NSString *)actionTitle cancelHandler:(void(^)())cancelHandler alertFinishHandler:(void(^)())alertFinishHandler object:(UIViewController *) object {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:alertTitle message:alertMessage preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:actionTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
        cancelHandler();
    }];

    [alert addAction:action];
    
    [object presentViewController:alert animated:YES completion:^{
        alertFinishHandler();
    }];
}



+ (void)alertViewControllerWithAlertTitle:(NSString *)alertTitle alertMessage:(NSString *)alertMessage  actionTitle:(NSString *)actionTitle confirmHandler:(void(^)())confirmHandler  alertFinishHandler:(void(^)())alertFinishHandler object:(UIViewController *) object {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:alertTitle message:alertMessage preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:actionTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        confirmHandler();
    }];
    
    [alert addAction:action];
    
    [object presentViewController:alert animated:YES completion:^{
        alertFinishHandler();
    }];
}

@end
